using HarmonyLib;
using UnityEngine;
using UnityEngine.UI;

namespace TheWorldOfKongfuEasyMod;

[HarmonyPatch(typeof(MenuController))]
[HarmonyPatch("OnButtonClick")]
public static class Patch_MenuController_OnButtonClick
{
    static void Prefix(ref MenuController __instance, GameObject go)
    {
        if (go == null || !go.activeInHierarchy || go.GetComponent<Button>() == null || !go.GetComponent<Button>().IsInteractable())
        {
            return;
        }
        
        if (go.name == "Auto")
        {
            Main.Logger.LogInfo("Auto");
            Data.isAutoBattle = true;
        }
        else if (go.name == "CancelAuto")
        {
            Main.Logger.LogInfo("CancelAuto");
            Data.isAutoBattle = false;
        }
    }
}